package com.csun.dsms.service.impl;

import com.csun.dsms.comment.core.support.BaseService;
import com.csun.dsms.mapper.DsmsLogMapper;
import com.csun.dsms.model.domain.DsmsLog;
import com.csun.dsms.model.domain.DsmsUser;
import com.csun.dsms.model.dto.log.LogQueryDto;
import com.csun.dsms.service.DsmsLogService;
import com.github.pagehelper.PageHelper;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author chisj chisj@foxmail.com
 * @version 1.0.0
 * @date 2021-08-31 14:40
 * @description: 日志接口实现类
 */
@Service
@Transactional
public class DsmsLogServiceImpl extends BaseService<DsmsLog> implements DsmsLogService {

    @Resource
    private DsmsLogMapper dsmsLogMapper;

    /**
     * 存储日志
     *
     * @param dsmsLog   the dsms log
     * @param user      the operator user
     *
     * @return  the int.
     */
    @Override
    public Integer save(DsmsLog dsmsLog, DsmsUser user) {

        dsmsLog.setUpdateInfo(user);

        return dsmsLogMapper.insertSelective(dsmsLog);
    }

    /**
     * 查询日志列表 - 分页.
     *
     * @param logQueryDto   the log query dto
     *
     * @return  the dsms log list.
     */
    @Override
    public List<DsmsLog> queryListWithPage(LogQueryDto logQueryDto) {

        PageHelper.startPage(logQueryDto.getPageNum(), logQueryDto.getPageSize());

        return dsmsLogMapper.queryListWithPage(logQueryDto);
    }
}
